package com.englishtest.city.service;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.englishtest.base.EnglishtestException;
import com.englishtest.base.Paginater;
import com.englishtest.city.dao.CityDao;
import com.englishtest.db.hibernate.HibernateUtils;
import com.englishtest.pojos.City;
import com.englishtest.pojos.College;
import com.englishtest.pojos.Fieldtime;

public class CityService {
	private static Log log = LogFactory.getLog(CityService.class);
	
	private CityDao cityDao;
	
	public void setCityDao(CityDao cityDao) {
		this.cityDao = cityDao;
	}

	public void saveCity(City city) throws EnglishtestException {
		HibernateUtils.saveOrUpdate(city);
	}
	
	public City getCity(Integer id) throws EnglishtestException {
		return (City)HibernateUtils.get(id, City.class);
	}
	
	public List searchCity(String searchWord, int isValid, Paginater paginater) {
		return cityDao.searchCity(searchWord, isValid, paginater);
	}
	
	public List searchCollege(String searchWord, Paginater paginater) {
		return cityDao.searchCollege(searchWord, paginater);
	}
	
	public void saveCollege(College college) throws EnglishtestException {
		HibernateUtils.saveOrUpdate(college);
	}
	
	public College getCollege(Integer id) throws EnglishtestException {
		return (College)HibernateUtils.get(id, College.class);
	}
	
	public List searchCollegeField(String searchWord, int isValid, Paginater paginater) {
		return cityDao.searchCollegeField(searchWord, isValid, paginater);
	}
	
	public Fieldtime getCollegeField(Integer id) throws EnglishtestException {
		return (Fieldtime)HibernateUtils.get(id, Fieldtime.class);
	}
	
	public void saveFieldtime(Fieldtime fieldtime) throws EnglishtestException {
		HibernateUtils.saveOrUpdate(fieldtime);
	}
}
